﻿var token = getCookie('signature');
houseCollectionNum();
houseCollectionStatus();
// houseInfoInformation()
lLlNum=0;//浏览量
zxNum=0;//咨询


setTimeout(function(){
  if(token){
      $('#logind').html('个人中心');
  }else{
      $('#logind').html('登录');
  }
},200)

function goLoginOr(){
  setTimeout(function(){
    if(token){
      window.location.href='/console/#/Home/Index'
    }else{
      window.location.href='/console/#/Login'
    }
  },200)
}


//点击周边推荐进去详情
function goToHouseDetails(name,id,ids){
  var visitNum = 0;
  ajax(
    "/api/v1/user/opt/countVisit",
    "post",
    {
      id: id,
      type: "3"
    },
    function(data) {
      visitNum = data.data;
    },
    function(err){
      visitNum = 0;
    }
  );
  window.location.href =
        '/three/fxfyxq.html?name=' + name + '&cut=0' + '&houseid=' + id + '&buildid=' + ids
}

function imgUrlYezf(e){
  window.event? window.event.cancelBubble = true : e.stopPropagation();
    $('#maskLayer').show();
}
function imgUrlYezf1(e){
  window.event? window.event.cancelBubble = true : e.stopPropagation();
    $('#inforImg').show();
}
function maskhide(){
  $('#maskLayer').hide();
}
function maskhide1(){
  $('#inforImg').hide();
}
// 获取收藏人数
function houseCollectionNum() {
  ajax(
    "/api/v1/user/opt/houseCollectionNum",
    "post",
    { houseId: getParams("houseid") },
    function(data) {
      $("#collection-num").html("收藏 " + data.data);
    }
  );
}
// 收藏房源
function houseCollection() {
  if (token) {
    ajax(
      "/api/v1/user/opt/addCollection",
      "post",
      { houseId: getParams("houseid") },
      function(data) {
        window.location.reload();
      }
    );
  } else {
    window.location.href =
      "/item/views/login/login.html";
  }
}
// 获取是否被收藏
function houseCollectionStatus() {
  var str = "";
  if (token) {
    ajax("/api/v1/user/opt/houseCollectionStatus", "post", { houseId: getParams("houseid") }, function(data) {
      if (data.data == "0") {
        str =
          "<a class='pull-left info-button' onclick='houseCollection()' >" +
          "<img src='static/ffyxq/images/favorite.svg' style='width: 13px;vertical-align: middle;'/>&nbsp;收 藏" +
          "</a>";
      } else {
        str =
        "<a class='pull-left info-button' style='background: #ccc'>"+
          "<img src='static/ffyxq/images/favorite.svg' style='width: 12px;' />&nbsp;已 收 藏"+
        "</a>"
      }
      $("#collection-img").html(str);
    });
  }else{
    str =
    "<a class='pull-left info-button' onclick='houseCollection()' >" +
    "<img src='static/ffyxq/images/favorite.svg' style='width: 13px;vertical-align: middle;'/>&nbsp;收 藏" +
    "</a>";
    $("#collection-img").html(str);
  }
}
// 搜索跳转
function goSearch() {
  var keywords = $("#keywords").val();
  window.location.href =
    "/item/views/search/searchBuildingHouse.html?keyword=" +
    keywords;
}
//回车搜索
function getkey(e){
  if(e.keyCode==13){
    goSearch()
  }
}
